//
//  CEPintHeaderSuperView.m
//  digitalCurrency
//
//  Created by apple on 2019/5/10.
//  Copyright © 2019 XinHuoKeJi. All rights reserved.
//

#import "CEPintHeaderSuperView.h"

@interface CEPintHeaderSuperView ()
@property (nonatomic, strong) UILabel *firstL;
@property (nonatomic, strong) UILabel *secondL;
@property (nonatomic, strong) UILabel *thirdL;

@property (nonatomic, strong) UIView *bottomView;

@end

@implementation CEPintHeaderSuperView

- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createviews];
    }
    return self;
}

- (void)createviews {
    if (self.firstL) {
        return;
    }
    CGFloat viewwidth = SCREEN_WIDTH-24;
    
    UIView *topview = [[UIView alloc] init];
    topview.backgroundColor = [UIColor colorWithHEX:mainBlackColor];
    topview.layer.cornerRadius = 5;
    [self addSubview:topview];
    [topview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(12);
        make.top.mas_equalTo(15);
        make.width.mas_equalTo(viewwidth);
        make.height.mas_equalTo(110);
    }];
    
    UILabel *title  = [[UILabel alloc] init];
    title.textColor = [UIColor whiteColor];
    title.text = LocalizationKey(@"Total performance (CT)");
    title.font = [UIFont boldSystemFontOfSize:14];
    self.headTitle = title;
    [topview addSubview:title];
    [title mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.top.mas_equalTo(30);
        make.width.mas_equalTo(viewwidth/2.0);
        make.height.mas_equalTo(14);
    }];
    
    UILabel *allcountLabel  = [[UILabel alloc] init];
    allcountLabel.textColor = [UIColor whiteColor];
    allcountLabel.text = @"0.00";
    allcountLabel.font = [UIFont boldSystemFontOfSize:24];
    [topview addSubview:allcountLabel];
    self.allcountLabel = allcountLabel;
    [allcountLabel mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.mas_equalTo(15);
        make.top.mas_equalTo(60);
        make.width.mas_equalTo(viewwidth-160);
        make.height.mas_equalTo(25);
    }];
    
    UIImageView *imageview = [[UIImageView alloc] initWithImage:[UIImage imageNamed:@"mine_shouye"]];
    [topview addSubview:imageview];
    [imageview mas_makeConstraints:^(MASConstraintMaker *make) {
        make.right.mas_equalTo(-12);
        make.top.mas_equalTo(15);
        make.height.width.mas_equalTo(75);
    }];
    
    self.bottomView = [[UIView alloc]init];
    [self addSubview:self.bottomView];
    [self.bottomView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.bottom.equalTo(0);
        make.height.equalTo(49);
    }];
    self.bottomView.backgroundColor = [UIColor colorWithHEX:mainBlackColor];
    self.bottomView.hidden = YES;
    
    for (int i = 0; i < 3; i++) {
        UILabel *firstL = [[UILabel alloc] init];
        firstL.textColor = [UIColor whiteColor];
        firstL.font = [UIFont systemFontOfSize:15];
        [self addSubview:firstL];
        if (i == 0) {
            self.firstL = firstL;
        }
        else if (i == 1) {
            self.secondL = firstL;
            firstL.textAlignment = NSTextAlignmentCenter;
        }
        else {
            self.thirdL = firstL;
            firstL.textAlignment = NSTextAlignmentRight;
        }
        
        [firstL mas_makeConstraints:^(MASConstraintMaker *make) {
            make.bottom.mas_equalTo(0);
            make.left.mas_equalTo(24 + (i*(viewwidth-24)/3.0));
            make.height.mas_equalTo(49);
            make.width.mas_equalTo((viewwidth-24)/3.0);
        }];
    }
    
    
}

- (void)setTitles:(NSArray *)titles {
    self.firstL.text  = titles[0];
    self.secondL.text = titles[1];
    self.thirdL.text  = titles[2];
    
    if ([titles[0]length] != 0) {
        self.bottomView.hidden = NO;
    }
}


@end
